package java_DesignPattern.BehavioralPattern.MementoPattern.write_box;

/**
 * 游戏角色类---发起人角色
 */
public class GameRole {

    private int vit = 100;
    private int atk = 100;
    private int def = 100;

    public void showStatus(){
        System.out.println("游戏角色当前状态：");
        System.out.println("vit:"+vit);
        System.out.println("atk:"+atk);
        System.out.println("def:"+def);
    }

    // 备份游戏角色状态
    public GameRoleMemento backup(){
        return new GameRoleMemento(vit,atk,def);
    }

    // 恢复游戏角色状态
    public void restore(GameRoleMemento memento){
        vit = memento.getVit();
        atk = memento.getAtk();
        def = memento.getDef();
    }

    // 游戏角色状态改变
    public void fight(){
        vit = 50;
        atk = 50;
        def = 50;
    }

    public int getVit() {
        return vit;
    }

    public void setVit(int vit) {
        this.vit = vit;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }
}
